package com.wlz.util;

import cn.hutool.http.HttpUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @author wlz
 * @date 2022-10-28  5:36 下午
 */
public class FilDownloadUtils {


    public static void main(String[] args) {
//        downloadImage("https://lbfota.bjev.com.cn/file/three/original-file/18c76c7d-69ff-4777-a38b-e209596f294b/37d63e02871a4c4188da98014b486c8f.zip");
//        downloadImage("http://fota.bjev.com.cn/file/three/original-file/04a1025c-ab12-42e0-b350-033327ca4c98/af09ab7fbf584f56984d6e007b09658d.zip");


        System.out.println(UUID.randomUUID().toString());


        int i = 5000 / 1000;

    }


    public static String downloadImage(String fileUrl) {
        long l = System.currentTimeMillis();
        String path = null;
        String staticAndMksDir = null;
        if (fileUrl != null) {
            //下载时文件名称
            String fileName = fileUrl.substring(fileUrl.lastIndexOf("."));
            try {
                String dataStr = new SimpleDateFormat("yyyyMMdd").format(new Date());
                String uuidName = UUID.randomUUID().toString();
                path = "/Users/wlz/Desktop/home/test/"+dataStr+"/"+uuidName+fileName;
                HttpUtil.downloadFile(fileUrl,path);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {

            }
        }
        System.out.println(System.currentTimeMillis()-l);
        return path;
    }
}
